/**
 * Witontek.com.
 * Copyright (c) 2012-2017 All Rights Reserved.
 */
package com.witon.witontool.core.model.db.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.witon.witontool.common.dal.pg.dao.DbConfigDao;
import com.witon.witontool.core.model.db.DbConfigRepository;
import com.witon.witontool.core.model.db.converter.DbConfigConverter;
import com.witon.witontool.core.model.db.model.DbConfig;

/**
 * 
 * @author Long
 * @version $Id: DbConfigRepositoryImpl.java, v 0.1 2017年6月29日 下午3:28:49  xiaolong.ma  Exp $
 */
@Repository
public class DbConfigRepositoryImpl implements DbConfigRepository {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    /**  */
    @Autowired
    private DbConfigDao  dao;

    /** 
     * @see com.witon.witontool.core.model.db.DbConfigRepository#queryList()
     */
    @Override
    public List<DbConfig> queryList() {
        logger.info("queryList");
        return DbConfigConverter.convertList(dao.queryList());
    }

    /** 
     * @see com.witon.witontool.core.model.db.DbConfigRepository#getById(long)
     */
    @Override
    public DbConfig getById(long id) {
        logger.info("getById id={}", id);
        return DbConfigConverter.convert(dao.getById(id));
    }

    /** 
     * @see com.witon.witontool.core.model.db.DbConfigRepository#add(com.witon.witontool.core.model.db.model.DbConfig)
     */
    @Override
    public long add(DbConfig model) {

        return dao.add(DbConfigConverter.convert(model));
    }

    /** 
     * @see com.witon.witontool.core.model.db.DbConfigRepository#deleteById(long)
     */
    @Override
    public int deleteById(long id) {
        return dao.deleteById(id);
    }

    /** 
     * @see com.witon.witontool.core.model.db.DbConfigRepository#update(com.witon.witontool.core.model.db.model.DbConfig)
     */
    @Override
    public int update(DbConfig model) {
        return dao.update(DbConfigConverter.convert(model));
    }

}
